function [data,data_trans] = generate_data_satis(N,J,mu_x,sigma_x,mu_z,sigma_z,alpha,beta,...
                                           mu_c,sigma_c)

% draw data

x = randn(N,J)*sigma_x + mu_x;
z = randn(N,J)*sigma_z + mu_z;

c = exp(randn(N,1)*sigma_c + mu_c);
epsilon = -evrnd(0,1,[N,J]);

choice = zeros(N,1);
open = zeros(N,J);

for i=1:N
       
    c_temp = c(i);
    
    % get which boxes are opened
    VU = alpha*x(i,:) + epsilon(i,:);
    [~,ind_sort] = sort(VU,'descend');
    
    U = alpha*x(i,:) + beta*z(i,:) + epsilon(i,:);
    
    j = 1;
    temp_search = 1;
    open_temp = [];
    while j<=J && temp_search==1
        
        open_temp = [open_temp ind_sort(j)];
        
        temp_search = (max(U(open_temp))<c_temp);
        
        j = j+1;
        
    end
    
    open_temp = ismember(1:J,open_temp);
    
    [~,max_temp] = max(U(logical(open_temp)));
    ind_temp = find(open_temp);
    choice(i) = ind_temp(max_temp);
    open(i,:) = open_temp;
    
end

data.x = x;
data.z = z;
data.c = c;
data.epsilon = epsilon;
data.choice = choice;
data.open = open;
% data.y = zeros(size(choice));
% data.y(choice==1) = 1;

data = struct2dataset(data);

data_trans = transform_data_01(data,J);

end

